﻿<%@ Page Title="" Language="C#" MasterPageFile="~/WorkstationHost.Master" AutoEventWireup="true"
    CodeBehind="ContentWorkstation.aspx.cs" Inherits="WorkstationDashboard.ContentWorkstation" %>

<%@ MasterType VirtualPath="~/WorkstationHost.Master" %>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">

    <script type="text/javascript">

        var processingDlg;
        var processingMsg;
        var headerMessage;
        var workstationId;

        $(document).ready(function() {
            processingDlg = $("#processingDlg");
            processingMsg = $("#processingMsg");
            headerMessage = $("#headerMessage");
            workstationId = $("#<%=workstationId.ClientID %>").val();
        });

        function removeWorkstation() {
            if (confirm("Are you sure to remove this Workstation? The related batteries and battery logs will be removed as well")) {

                processingDlg.dialog("open");
                processingMsg.html("Removing Workstation...");

                PageMethods.RemoveWorkstation(workstationId, onRemoveSucceed, onRemoveFail);
            }
        }

        function onRemoveFail(error) {
            var errorMsg = error.get_message();
            processingMsg.addClass("ui-state-error");
            processingMsg.html(errorMsg);
        }

        function onRemoveSucceed() {
            processingMsg.html("Workstation is removed");
            setTimeout(function() {
                processingDlg.dialog("close");
                location.href = "ContentRoot.aspx";
            }, 2000);
        }
    </script>

</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" runat="server">
    <div class="ui-helper-hidden">
        <asp:HiddenField ID="workstationId" runat="server"></asp:HiddenField>
    </div>
    <div>
        <div id="processingDlg">
            <div id="processingMsg" class="ui-state-default">
            </div>
        </div>

        <script type="text/javascript">
            $("#processingDlg").dialog({ autoOpen: false, modal: true });
        </script>

    </div>
    <div class="ui-layout-center" style="display: none">
        <div id="headerMessage">
        </div>
        <div>
            <h2>
                Workstation -
                <asp:Label ID="workstationName" runat="server"></asp:Label>
            </h2>
        </div>
        <div>
            <div>
                Name:
                <asp:Label ID="workstationName2" runat="server"></asp:Label></div>
            <div>
                IP Address:
                <asp:Label ID="workstationIP" runat="server"></asp:Label></div>
                      <div>
                OS Version:
                <asp:Label ID="osVersion" runat="server"></asp:Label></div>
            <div>
                Note:
                <asp:Label ID="workstationNote" runat="server"></asp:Label></div>
        </div>
    </div>
    <div class="ui-layout-east" style="display: none">
        <h3>
            Tasks
        </h3>
        <div>
            <div>
                <input id="removeButton" type="button" onclick="removeWorkstation()" value="Remove Workstation" />
            </div>
        </div>
    </div>
</asp:Content>
